<template>
  <rx-dialog @handOk="handleSubmit" @cancel="cancel">
    <rx-layout>
      <div slot="center">
        <a-form-model ref="form" :model="mdl" :rules="rules">
          <a-form-model-item style="display: none">
            <a-input v-model="mdl.id"/>
          </a-form-model-item>
          <a-row>
            <a-col :span="24">
              <a-form-model-item :labelCol="labelCol1" :wrapperCol="wrapperCol1" :label="i18n('form.archiveDate','归档日期')" prop="archiveDate">
                <a-date-picker :placeholder="i18n('form.archiveDate','归档日期','input')" v-model="mdl.archiveDate" :disabled-date="disabledDate"/>
              </a-form-model-item>
            </a-col>
          </a-row>
          <a-row>
            <a-col :span="24">
              <a-form-model-item :labelCol="labelCol1" :wrapperCol="wrapperCol1" :label="$ti18('rxForm.notes','备注')" prop="memo">
                <a-textarea :placeholder="$ti18('rxForm.notes','备注')" v-model="mdl.memo" :rows="4"/>
              </a-form-model-item>
            </a-col>
          </a-row>
          <a-row>
            <a-col :span="24">
              <a-form-model-item :labelCol="labelCol1" :wrapperCol="wrapperCol1" :label="i18n('form.pointsForAttention','注意事项')">
                <span style="color: #ff2222">
                    {{i18n('form.pointOut','在归档之前请先做好备份，一旦归档过程中出现问题，可以进行恢复。')}}
                </span>
              </a-form-model-item>
            </a-col>
          </a-row>
        </a-form-model>
      </div>
    </rx-layout>
  </rx-dialog>
</template>
<script>
  import BpmArchiveLogApi from '@/api/bpm/core/bpmArchiveLog'
  import {BaseFormModel, RxDialog} from '@lowcode/jpaas-common-lib';
  import moment from 'moment';

  export default {
    name: 'BpmArchiveLogEdit',
    mixins: [BaseFormModel],
    components: {
      RxDialog,
    },
    data() {
      return {
        rules: {
          archiveDate: [{required: true, message: this.i18n('form.archiveDate','归档日期','input'), trigger: 'change'}],
          memo: [{required: false, message: this.$ti18('rxForm.notes','备注','input'), trigger: 'change'}],
        }
      }
    },
    methods: {
        i18n(name,text,key){
            return this.$ti18(name,text,"bpmArchiveLog",key);
        },
      get(id) {
        return BpmArchiveLogApi.get(id);
      },
      save(values) {
        values.archiveDate=values.archiveDate.format("YYYY-MM-DD HH:mm:ss");
        return BpmArchiveLogApi.save(values);
      },
      //只能选择之前的日期
      disabledDate(current) {
        return current && current > moment().endOf('day');
      },

    }
  }
</script>